home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / printing / hputils.arc / DJETBOOT / DJETBOOT.C next >
C/C++ Source or Header  |  1990-04-01  |  3KB  |  132 lines

  1.  
  2. #include <osbind.h>
  3. #include <bios.h>
  4.  
  5.  
  6.  
  7. #define FVERIFY ((int *) 0x0444L)
  8. #define PHYSTOP ((long *) 0x42E)
  9.  
  10. #define BOOLEAN int
  11. #define TRUE 1
  12. #define FALSE 0
  13.  
  14.  
  15.  
  16. void itoa(n,s)
  17.    register int
  18.       n;
  19.    register char
  20.       *s;
  21. {
  22.    /*
  23.       Fast and small integer to ASCII conversion; leaves off leading
  24.       zeroes.
  25.    */
  26.    register int
  27.       digit,divisor;
  28.    register BOOLEAN
  29.       leading = TRUE;
  30.  
  31.    for (divisor = 10000; divisor; n %= divisor, divisor /= 10)
  32.       if ((digit = n/divisor) || !leading) {
  33.          *s++ = digit+'0';
  34.          leading = FALSE;
  35.       }
  36.    *s = '\0';
  37. } /* itoa */
  38.  
  39.  
  40.  
  41. void write_s(dev,s)
  42.    register int
  43.       dev;
  44.    register char
  45.       *s;
  46. {
  47.    /*
  48.       Write a string; user can't abort program with ctrl-C, pause
  49.       listing, etc., as with Cconws.
  50.    */
  51.    while (*s)
  52.       Bconout(dev,*s++);
  53. } /* write_s */
  54.  
  55.  
  56.  
  57. main()
  58. {
  59.    register int
  60.       c;
  61.    register long
  62.       map;
  63.    char
  64.       s1[20],s2[20];
  65.    long
  66.       save_ssp;
  67.  
  68.    write_s(2,"E"); /* clear screen */
  69.    write_s(2,"\n/*--------------------*/\r\n");
  70.    write_s(2,"/*  p DeskJet Booter q  */\r\n");
  71.    write_s(2,  "/*  by Doug Harrison  */\r\n");
  72.    write_s(2,  "/*--------------------*/\r\n\n\np");
  73.  
  74.    save_ssp = Super(0L); /* Enter supervisor */
  75.  
  76. /*
  77.    Uncomment this to disable floppy write with verify. I used to do this,
  78.    but unfortunately it also turns off ICD's hard drive booter's verify
  79.    mode, which uses this location as a flag.
  80.  
  81.    *FVERIFY = 0;
  82. */
  83.  
  84.    itoa((int) (*PHYSTOP/1024),s1); /* total memory */
  85.  
  86.    Super(save_ssp); /* Exit supervisor */
  87.  
  88.    itoa((int) (Malloc(-1L)/1024),s2); /* largest free block */
  89.  
  90.    /*
  91.       Display total RAM and "free" RAM.
  92.    */
  93.    write_s(2,s1);
  94.    write_s(2,"K computer, with ");
  95.    write_s(2,s2);
  96.    write_s(2,"K free.\r\n\n");
  97.  
  98.    /*
  99.       Display active drives.
  100.    */
  101.    write_s(2,"Drives: ");
  102.    for (map = Drvmap(), c = 'A'; map; c++) {
  103.       if (map & 1)
  104.          Bconout(2,c);
  105.       if ((map >>= 1) & 1)
  106.          Bconout(2,',');
  107.    }
  108.  
  109.    write_s(2,".\r\n\n");
  110.    if (Cprnos()) {
  111.       /*
  112.          This check of the printer status is confounded if a spooler is
  113.          active; well if Migraph's OSpooler is active, anyway. But this
  114.          accessory can only be active at the GEM level, so it isn't a
  115.          problem when running DJETBOOT from the AUTO folder. Not sure
  116.          what other spoolers will do here.
  117.       */
  118.       write_s(0,"(s1Q");
  119.       write_s(2,"DeskJet Print Quality set to Draft.\r\n");
  120.    }
  121.    else
  122.       write_s(2,"DeskJet isn't online...\r\n");
  123. /*
  124.    Uncomment this to get the nice message.
  125.  
  126.    write_s(2,"Write verify turned OFF.\r\n\n");
  127. */
  128.    write_s(2,"\r\n\nq"); /* normal video */
  129.    exit(0);
  130. } /* main */
  131.  
  132.